import java.util.Scanner;

class FI{
    public int Fibonacci(int n){
        if (n==1||n==2) return 1;
        if (n==0) return 0;
        return Fibonacci(n-1)+Fibonacci(n-2);
    }


}



public class Text1 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        FI d = new FI();
        int i=0;
        while(Math.abs(d.Fibonacci(i)-n)>=Math.abs(d.Fibonacci(i+1)-n)){
            i++;
        }
        System.out.println(Math.abs(d.Fibonacci(i)-n));
    }
}
